package com.lloydfinch.multirecyclerview

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.lloydfinch.multirecyclerview.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        binding.recyclerView.layoutManager = LinearLayoutManager(this)

        val beans = ArrayList<BaseItemBean>()
        for (i in 0..100) {
            val terminalTime = System.currentTimeMillis() + i * 10_000
            beans.add(BaseItemBean(i.toLong(), terminalTime, (i % 2) + 1))
        }

        val adapter = Adapter(beans)
        adapter.onItemDeleteClick = { position ->
            beans.removeAt(position)
            adapter.notifyItemRemoved(position)
        }
        binding.recyclerView.adapter = adapter

    }
}